package com.xd.user.api.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xd.common.base.BaseModel;
import com.xd.common.constant.CommonConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Exrick
 */

@Data
@Accessors(chain = true)
@TableName("xd_department")
@Table(name = "xd_department")
@org.hibernate.annotations.Table(appliesTo = "xd_department", comment = "权限")
@Entity
@ApiModel("部门")
public class Department extends BaseModel<Department> {

    private static final long serialVersionUID = 1L;

    /**
     * 部门名称
     */
    @ApiModelProperty(value = "部门名称")
    @Column(nullable = false, columnDefinition = "varchar(100) default '' comment '部门名称'")
    private String title;
    /**
     * 父id
     */
    @ApiModelProperty(value = "父id")
    @Column(nullable = false, columnDefinition = "varchar(255) default '0' comment '父id '")
    private String parentId;
    /**
     * 是否为父节点(含子节点) 默认false
     */
    @ApiModelProperty(value = "是否为父节点(含子节点) 默认false")
    @Column(nullable = false, columnDefinition = "bit default false comment'是否为父节点(含子节点) 默认false'")
    private Boolean isParent = false;
    /**
     * 排序值
     */
    @ApiModelProperty(value = "排序值")
    @Column(precision = 10, scale = 2, columnDefinition = "decimal default 0 comment '排序值 '")
    private BigDecimal sortOrder;
    /**
     * 是否启用 0启用 -1禁用
     */
    @ApiModelProperty(value = "是否启用 0启用 -1禁用")
    @Column(nullable = false, columnDefinition = "Integer(2) default 0 comment '是否启用 0启用 -1禁用'")
    private Integer status = CommonConstant.STATUS_NORMAL;
    /**
     * 父节点名称
     */
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "父节点名称")
    private String parentTitle;
    /**
     * 主负责人
     */
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "主负责人")
    private List<String> mainHeader;
    /**
     * 副负责人
     */
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "副负责人")
    private List<String> viceHeader;

    /**
     * 子节点
     */
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "子节点")
    private List<Department> departments = new ArrayList<>();


    public static void main(String[] args) {
        System.out.println("这是个main方法");
    }
}
